-
Notifications
You must be signed in to change notification settings - Fork 422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tracker health check client #378
Conversation
b5627eb
to
4801c88
Compare
4801c88
to
2d3c637
Compare
@@ -89,6 +92,18 @@ func getEndpoint(version int, addr string, h core.InfoHash) (method, url string) | |||
return "POST", fmt.Sprintf("http://%s/announce/%s", addr, h.String()) | |||
} | |||
|
|||
func (c *client) CheckHealth() error { | |||
addr := c.ring.Locations(backend.ReadinessCheckDigest)[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sanity check to see if the ring Locations is not empty.
locations := c.ring.Locations(backend.ReadinessCheckDigest)
if len(locations) == 0 {
return fmt.Errorf("no locations available for health check")
}
addr := locations[0]
addr := c.ring.Locations(backend.ReadinessCheckDigest)[0] | ||
_, err := httputil.Get( | ||
fmt.Sprintf("http://%s/health", addr), | ||
httputil.SendTimeout(2*time.Second), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
making this configurable would be a nice to have.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments rest Looks good to me.
ab090d4
to
1386190
Compare
Turns out that the tracker's readiness is not equal to its health. The tracker must check the origin's readiness. Thus a client for the health endpoint is not required. Instead a readiness endpoint will be implemented in #380 |
As described in #371, all services should implement a "readiness" endpoint, which checks whether the service is ready to serve traffic, i.e. whether it can reach all of its dependencies. The agent's readiness endpoint will check whether it has any healthy trackers available (as it needs to query a tracker to get data about where a torrent can be found). Thus, the agent needs a client for the tracker's health endpoint.
Add health check client endpoint for tracker, which queries its health endpoint.
Stacked on top of #377